/*
 * @Author: ecitlm 
 * @Date: 2017-07-19 17:11:18 
 * @Last Modified by: ecitlm
 * @Last Modified time: 2017-07-20 09:58:46
 */

//音乐详情信息
const express = require('express')
const app = express()

app.get('/', function(req, res) {

    var ipInfo = getClientIp(req);
    res.send(ipInfo);
    console.log(err)

});

function getClientIp(req) {
    var ipAddress;
    var forwardedIpsStr = req.header('x-forwarded-for');
    if (forwardedIpsStr) {
        var forwardedIps = forwardedIpsStr.split(',');
        ipAddress = forwardedIps[0];
    }
    if (!ipAddress) {
        ipAddress = req.connection.remoteAddress;
    }
    return ipAddress;
}

module.exports = app;